"use strict";
cc._RF.push(module, 'c14b1iNRXtJqrU0j6ZcoQDc', 'cell');
// scripts/cell.js

"use strict";

cc.Class({
    extends: cc.Component,

    properties: {
        id: 0,
        arrayI: 0,
        arrayJ: 0,

        number: 0,
        IsSurePut: true
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start: function start() {
        this.IsSurePut = true; //可以放入
    },

    //显示子物体
    subObject: function subObject(_number) {
        this.IsSurePut = false;
        this.number = _number;

        var _sub = cc.find("innercell", this.node); //显示子物体
        _sub.active = true;

        var _color = void 0;
        for (var i = 0; i < cellColor.length; i++) {
            if (this.number == cellColor[i].num) {
                _color = cellColor[i].color;
            }
        }
        _sub.color = cc.color(_color);

        var _subNumber = cc.find("innercell/number", this.node); //数字
        _subNumber.getComponent(cc.Label).string = this.number;

        this.replyColor();
    },

    //隐藏子物体
    hideObject: function hideObject() {
        this.IsSurePut = true;
        var _sub = cc.find("innercell", this.node); //显示子物体
        _sub.active = false;
    },

    //克隆子物体 移动
    cloneMoveSubObject: function cloneMoveSubObject() {
        var _sub = cc.find("innercell", this.node); //子物体

        var cioneSub = cc.instantiate(_sub);
        var _innerCellInterface = cc.find("Canvas/innerCellInterface");
        _innerCellInterface.setPosition(this.node.x, this.node.y);
        _innerCellInterface.addChild(cioneSub);

        _sub.active = false; //隐藏子物体
    },


    //回复颜色
    replyColor: function replyColor() {
        this.node.color = cc.color("#ffffff");
    },

    //第一次碰撞
    onCollisionEnter: function onCollisionEnter(other, self) {
        if (this.IsSurePut == true) {
            // console.log("碰撞");
            this.node.color = cc.color("#0000ff");
        }
    },
    //持续碰撞
    onCollisionStay: function onCollisionStay(other, self) {},
    //离开碰撞
    onCollisionExit: function onCollisionExit(other, self) {
        if (this.IsSurePut == true) {
            this.node.color = cc.color("#ffffff");
        }
    }

    // update (dt) {},
});

cc._RF.pop();